
/**
 * @file VarAnalysis/Home.js
 *  var
 * @author
 */

import React, {Component,PropTypes} from 'react';
import {connect} from 'dva';
import {routerRedux,Link,withRouter } from 'dva/router';
import { Button,Modal,Row,Col,Table,Icon,Card} from 'antd';
import _ from 'lodash';

import Tabtitle from '../../../components/common/TabTitle';
import { Vartable,Toolbar,OverDataTable,VarChart,MyCharts } from '../components';
import styles from './home.less';

const VarAnalysis = ({dispatch,varanalysis,location}) => {
	const {status,vartable,overallData,lineData,defaultvarzuhe,varzuhelist,varjizhunlist,defaultvarjizhun} = varanalysis;
	console.log('varanalysis---------',varanalysis)
	if(varanalysis.status){
			const handleChangeRangePicker=(value)=> {
			dispatch({
					payload: {
						beginDate:value[0].format("YYYYMMDD"),
						endDate:value[1].format("YYYYMMDD")
					}
				})
			}
			const toolbar = {
				groupVarzuheSelect:{
					data:varzuhelist,
					defaultValue:defaultvarzuhe,
					style:{width:120},
				},
				groupVarjizhunSelect:{
					data:varjizhunlist,
					defaultValue:defaultvarjizhun,
					style:{width:120},
				},
				rangePicker:{
					// defaultValue:beginDate&&endDate?[moment(beginDate), moment(endDate)]:[null, null],
					onChange:handleChangeRangePicker,
					style:{width:130}
				},
			}
			
				return (
					<div>
						<Tabtitle value={'VaR分析'}/>
						<div className="page-varanalysis-home content-inner">
							<Toolbar {...toolbar}/>
								<Card>
									<Vartable dataSource={vartable} />
								</Card>
								<Row>
									<Col span={14}>
										<Card>
											<VarChart data={lineData} />
										</Card>
									</Col>
									<Col span={10}>
										<Card>
											<OverDataTable dataSource={overallData} />
										</Card>
									</Col>
								</Row>\
						</div>
					</div>
				)
			}else{
				return null;
			}
				
			
}

VarAnalysis.propTypes = {
}

export default connect(({varanalysis})=>({varanalysis}))(VarAnalysis)